<template>
    <div class="calendar-container" v-loading="showLoading">
        <div v-if="calendarShowType == 2" style="margin-top: -20px;padding-bottom: 10px;">
            <div style="width: 100%;display: flex;">
                <div style="width: 25%;">
                    <div>线上媒体</div>
                    <div style="margin-left: 25%;">
                        <div v-for="(item, index) in onlineMediumList" :key="index">
                            <div style="min-height: 30px;">{{ item.mediumName }}</div>
                        </div>
                    </div>
                </div>
                <div style="border-left: 1px solid #ccc;margin-right: 20px;"></div>
                <div style="width: 75%;">
                    <div>线下媒体</div>
                    <div style="margin-left: 10%;">
                        <div style="display: flex;margin-top: -15px;margin-bottom: 10px;">
                            <div style="max-width: 150px;width: 150px;">名称</div>
                            <div style="padding-left: 20px;max-width: 80px;width: 80px;">总数</div>
                            <div style="padding-left: 20px;max-width: 100px;width: 100px;">剩余未排期</div>
                            <div style="padding-left: 20px;">排期</div>
                        </div>
                        <div v-for="(item, index) in offlineMediumList" :key="index" style="margin-bottom: 10px;">
                            <div style="display: flex;min-height: 30px;">
                                <div style="max-width: 150px;width: 150px; text-align: center; align-items: center;display: flex;cursor: pointer"
                                    @click="viewOneMedium(item)">
                                    {{ item.mediumName }}
                                </div>
                                <div
                                    style="padding-left: 20px;max-width: 80px;width: 80px; text-align: center; align-items: center;display: flex;">
                                    {{ item.totalNum }}
                                </div>
                                <div
                                    style="padding-left: 20px;max-width: 100px;width: 100px; text-align: center; align-items: center;display: flex;">
                                    {{ item.hasJoinNum }}
                                </div>
                                <div style="padding-left: 20px;display: flex; align-items: center;">
                                    <div style="width: 350px;display: flex;" v-if="item.dateString">
                                        {{ item.dateString }}
                                    </div>
                                    <div style="padding-left: 10px;" v-if="item.hasJoinNum && item.hasJoinNum > 0">
                                        <el-button type="text" @click="chooseMediumTime(item, index)">{{
                                            mediumChooseStatus &&
                                            chooseTitleMediumIndex == index ? '已选择' : '选择时间' }}</el-button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="body-box"> <!--@scroll="handleScroll" -->
            <div class="calendar-body">
                <div class="calendar-body-content">
                    <div class="calendar-body-content-body" @wheel="handleWheel" v-on:scroll="windowScrollEnd">
                        <div class="calendar-body-content-body1 fixed-header"
                            :class="{ 'sticky-header sticky-column': index === 0, 'paiduiwei': item.isExtra }"
                            v-for="(item, index) in dataOfflineShowList" :key="index">
                            <div v-if="item.name" class="calendar-body-content-body-name sticky-column">
                                <div class="calendar-body-content-body-item">
                                    <div class="calendar-body-content-body-item-content">
                                        <div class="calendar-body-content-body-item-content-time">
                                            <el-tooltip class="item" effect="dark" :content="item.name" placement="top">
                                                <span class="calendar-body-content-body-item-content-time-text ">
                                                    {{ item.name }}
                                                </span>
                                            </el-tooltip>
                                        </div>
                                        <div v-if="item.isExtra" style="font-size: 12px;color: #ccc;">排队位</div>
                                    </div>
                                </div>
                            </div>
                            <div class="calendar-body-content-header" v-else>
                                <div class="calendar-body-content-header-item" v-for="(itemDate, index) in dateList"
                                    :key="index">
                                    <div v-if="itemDate.date && itemDate.date == '线下媒体'" class="corner-cell">
                                        <el-select v-model="mediumIds" placeholder="请选择" clearable
                                            @change="changeMedium" multiple filterable>
                                            <el-option v-for="mediumItem in mediumList" :key="mediumItem.id"
                                                :label="mediumItem.name" :value="mediumItem.id">
                                            </el-option>
                                        </el-select>
                                    </div>
                                    <div v-else>
                                        <div class="calendar-body-content-header-item-text">
                                            <div> {{ itemDate.date }} </div>
                                            <div> 星期{{ itemDate.week }}</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div v-if="item.name && item.projectMsgDTOList && item.projectMsgDTOList.length > 0"
                                class="calendar-body-content-item">
                                <div id="calendarChoose" class="calendar-body-content-body2-item"
                                    @contextmenu.prevent="onContextmenu($event, item, index, dateItem, dateIndex)"
                                    @click="chooseDateClick(item, index, dateItem, dateIndex)"
                                    v-on:mouseover="hoverDateItem(dateItem)"
                                    v-for="(dateItem, dateIndex) in item.projectMsgDTOList" :key="dateIndex"
                                    @dragstart="dragstart($event, dateItem, index, dateIndex)"
                                    @dragend="dragend($event, dateItem, index, dateIndex)"
                                    @drag="drag($event, dateItem, index, dateIndex)"
                                    @dragleave="dragleave($event, dateItem, index, dateIndex)"
                                    @dragover="dragover($event, dateItem, index, dateIndex)"
                                    :draggable="dateItem && dateItem.projectList && dateItem.projectList.length > 0 && projectId && dateItem.projectList[0].projectId != projectId ? false : projectId ? true : false"
                                    ondragover="return false" :class="(dateItem && dateItem.hasChoose) 
                                    ? (dateItem.projectList && dateItem.projectList.length > 0 && dateItem.projectList[0].sureType
                                      ? (dateItem.projectList[0].sureType === 1
                                        ? 'calendar-body-content-body2-item-choose1'
                                        : (dateItem.projectList[0].sureType === 2
                                          ? 'calendar-body-content-body2-item-choose2'
                                          : (dateItem.projectList[0].sureType === 3
                                            ? 'calendar-body-content-body2-item-choose3'
                                            : (dateItem.projectList[0].sureType === 4
                                              ? 'calendar-body-content-body2-item-choose4'
                                              : 'calendar-body-content-body2-item-choose5' 
                                            )
                                          )
                                        )
                                      )
                                      : 'calendar-body-content-body2-item-choose5'
                                    )
                                    : ''">
                                    <!--:style="dateItem && dateItem.projectList && dateItem.projectList.length > 0 && projectId && dateItem.projectList[0].projectId == projectId ? 'background-color: #fdc7c7' : ''" -->
                                    <div class="calendar-body-content-body-item-content">
                                        <div class="calendar-body-content-body-item-content-project"
                                            v-if="dateItem && dateItem.projectList && dateItem.projectList.length > 0">
                                            <span class="calendar-body-content-body-item-content-project-text"
                                                v-for="(projectItem, projectIndex) in dateItem.projectList"
                                                :key="projectIndex">
                                                <div
                                                    style="text-overflow: ellipsis;white-space: nowrap;overflow: hidden;">
                                                    {{ projectItem.brands }}</div>
                                                <div>{{ projectItem.createUserName }}</div>
                                            </span>
                                        </div>
                                        <div class="calendar-body-content-body-item-content-time" v-else>
                                            <span class="calendar-body-content-body-item-content-time-text">
                                                {{ '' }}
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 新增编辑其他项目 -->
        <el-dialog :title="formTitle" :visible.sync="addMediumOtherProjectDialogVisible" width="50%"
            :before-close="addMediumOtherProjectHandleClose">
            <div>
                <el-form :model="addMediumOtherProjectForm" :rules="addMediumOtherProjectRules"
                    ref="addMediumOtherProjectForm" label-position="right" label-width="80px">
                    <el-form-item label="项目名称" prop="projectName" :label-width="formLabelWidth">
                        <el-input v-model="addMediumOtherProjectForm.projectName" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="类型" prop="otherProjectType" :label-width="formLabelWidth">
                        <el-select v-model="addMediumOtherProjectForm.otherProjectType" placeholder="请选择">
                            <el-option v-for="(item, index) in otherProjectTypeList" :key="index"
                                :label="item.sysValueName" :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="品牌" prop="brands" :label-width="formLabelWidth">
                        <el-input v-model="addMediumOtherProjectForm.brands" autocomplete="off"></el-input>
                    </el-form-item>
                </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="addMediumOtherProjectDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="addMediumOtherProjectSubmit">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 选择项目弹窗 -->
        <el-dialog :title="chooseProjectTitle" :visible.sync="chooseMediumOtherProjectDialogVisible" width="50%"
            :before-close="chooseMediumOtherProjectHandleClose">
            <div>
                <div class="device-list">
                    <ul class="global-operation-list" style="margin-top: 20px;">
                        <li class="global-operation-left">
                            <ul class="global-filter-list">
                                <li class="global-filter-item">
                                    <h2 class="global-filter-item-title">关键字：</h2>
                                    <el-input v-model="searchForm.keyword" @change="reProjectPosts"
                                        placeholder="项目名称、品牌" clearable></el-input>
                                </li>
                                <li class="global-filter-item" v-if="chooseProjectType == 3">
                                    <h2 class="global-filter-item-title">类型：</h2>
                                    <el-select v-model="searchForm.otherProjectType" placeholder="请选择类型" clearable>
                                        <el-option v-for="item in otherProjectTypeList" :key="item.id"
                                            :label="item.sysValueName" :value="item.id">
                                        </el-option>
                                    </el-select>
                                </li>
                                <li class="global-filter-item">
                                    <el-button type="primary" class="global-filter-item-search"
                                        :style="{ background: $store.state.theme.theme_color || '#03C192', border: 'none' }"
                                        @click="reProjectPosts()">搜索</el-button>
                                </li>
                            </ul>
                        </li>
                    </ul>
                    <div class="global-table-content">
                        <div class="global-table">
                            <el-table :data="dataList" :header-cell-style="{
        background: '#F6F7FA',
        color: '#333',
        height: '60px',
    }" v-loading="tableLoading" :row-style="{ height: '0' }" :cell-style="{ padding: '3px' }" max-height="700" border
                                highlight-current-row @current-change="handleCurrentChangeTable"
                                v-if="dataList && dataList.length > 0">
                                <el-table-column prop="projectName" label="项目名称" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column label="品牌名称" prop="brands" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column label="项目类型" prop="otherProjectTypeName" v-if="chooseProjectType == 3"
                                    show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column label="创建时间" prop="createDate" show-overflow-tooltip>
                                </el-table-column>
                            </el-table>
                            <div class="no-data" v-else
                                style="height: calc(100vh - 130px - 80px);display: flex;align-items: center;justify-content: center;flex-direction: column">
                                <img style="width: 265px;height: 120px;margin-bottom: 32px"
                                    src="@/assets/images/tyNoData.png" alt="" />
                                <div style="font-size: 16px;color: #A5A9B5">暂无数据~</div>
                            </div>
                        </div>
                        <div class="global-page">
                            <div class="global-page-left">
                            </div>
                            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                                :page-sizes="pageSizes" :page-size="pageSize" :current-page="pageNum" background
                                layout="sizes, total, prev, pager, next" :total="total">
                            </el-pagination>
                        </div>
                    </div>
                </div>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="chooseMediumOtherProjectDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="commitChooseMediumProject">确 定</el-button>
            </span>
        </el-dialog>

        <manageUserChoose @getChooseUserId="getChooseUserId" :roleIds="manageUserRoleIds"
            :isOpen="manageUserChooseOpen" @closeChooseUser="closeChooseUser">
        </manageUserChoose>
    </div>
</template>

<script>
import Vue from 'vue'
import Contextmenu from "vue-contextmenujs"
Vue.use(Contextmenu);
import APIProject from "@/api/apiProject";
import APIMediumOtherProject from "@/api/apiMediumOtherProject";
import APISysLabel from "@/api/apiSysLabel";
import draggable from "vuedraggable";
import manageUserChoose from "@/components/ManageUser";
export default {
    name: "Calendar",
    components: {
        // draggable,
        manageUserChoose,
    },
    props: {
        dataOfflineList: Array,
        calendarStartTime: Number,
        calendarEndTime: Number,
        calendarType: Number,
        calendarScrollLeftStatus: Boolean,
        projectChooseMap: Object,
        calendarShowType: Number, // 2、展示线上线下信息
        onlineMediumList: Array,
        offlineMediumList: Array,
        chooseShowAddIndex: Number,
        projectId: Number,
        brands: String,
        projectName: String,
        operationList: Array,
        showButtonType: Number,
        chooseProjectMsg: Object,
        sureType: Number,
        showCleanDateType: Number,
        endDayNum: Number,
    },
    watch: {
        showCleanDateType(val){
            if(val && val == 10){
                this.dateList = [];
            }
        },
        calendarStartTime(val) {
            if (val) {
                if (!this.calendarStartTimeShow) {
                    this.calendarStartTimeShow = val
                } else {
                    if (this.calendarStartTimeShow > val) {
                        this.calendarStartTimeShow = val
                    }
                }
            }
        },
        calendarEndTime(val) {
            if (val) {
                if (!this.calendarEndTimeShow) {
                    this.calendarEndTimeShow = val
                } else {
                    if (this.calendarEndTimeShow < val) {
                        this.calendarEndTimeShow = val
                    }
                }
            }
        },
        dataOfflineList(val) {
            // if (!this.showCleanDateType && this.showCleanDateType != 0 && this.showCleanDateType != -1 && this.showCleanDateType != 1) {
            //     this.dateList = [];
            // }
            let list = val
            if (list.length > 0) {
                this.getChooseDate();
            }
        },
        dateList(val) {
            this.getChooseDate();
        },
        calendarType(val) {
            if (val) {
                if (this.calendarStartTime && this.calendarEndTime && this.calendarStartTime == this.calendarEndTime) {
                    this.dateList = []
                }
                this.getDate();
            }
        },
        calendarScrollLeftStatus(val) {
            if (val) {
                let html = document.querySelector(".calendar-body-content-body");
                html.scrollLeft = 0;
                this.dateList = [];
            }
        },
    },
    mounted() {
        this.dateList = []
        this.getDate()
        let html = document.querySelector(".calendar-body-content-body");
        html.scrollLeft = 0;
        html.addEventListener("wheel", function (event) {
            if(!event.shiftKey){
            let dundong = -event.wheelDelta;
            html.scrollLeft = html.scrollLeft + dundong;
            event.preventDefault();
            }
        });
        this.$bus.$on('clearSearchParams', () => {
            this.mediumIds = []
        })
    },
    created() {
        this.scrollStatusType = 1
        this.dateList = []
    },
    data() {
        return {
            dateList: [
                {
                    date: '线下媒体',
                },
            ],
            mediumList: [],
            loading: false,
            mediumIds: [],
            dataOfflineShowList: [],
            mediumChooseStatus: false,
            chooseId: null,
            showLoading: false,
            chooseTitleMediumIndex: null,
            evtChangeStartItem: {},
            evtChangeStartIndex: null,
            evtChangeEndIndex: null,
            evtChangeEndDateIndex: null,
            evtChangeEndDate: null,
            modelList: [],
            scrollStatusType: 1, //左右滑动状态, 2: 左滑 3: 右滑
            calendarStartTimeShow: null,
            calendarEndTimeShow: null,
            otherProjectTypeList: [],
            addMediumOtherProjectDialogVisible: false,
            addMediumOtherProjectForm: {
                id: null,
                projectName: '',
                otherProjectType: null,
                brands: '',
            },
            addMediumOtherProjectRules: {
                projectName: { required: true, message: '请输入项目名称', trigger: 'blur' },
                otherProjectType: { required: true, message: '请选择类型', trigger: 'change' },
                brands: { required: true, message: '请输入品牌', trigger: 'blur' },
            },
            formTitle: '新增其他项目',
            formLabelWidth: '120px',
            chooseItemLeftIndex: null,
            chooseItemTopIndex: null,
            chooseMediumOtherProjectDialogVisible: false,
            chooseProjectId: null,
            chooseProjectName: null,
            chooseBrands: null,
            chooseProjectType: 3,
            tableLoading: false,
            dataList: [],
            pageSize: 10,
            pageNum: 1,
            total: 0,
            pageSizes: [10, 20, 50, 100],
            searchForm: {
                keyword: "",
                otherProjectType: null,
            },
            chooseProjectTitle: '选择项目',
            userInfo: JSON.parse(localStorage.getItem('mujinguserInfo')),
            manageUserRoleIds: '',
            chooseMediumDateId: null,
            manageUserChooseOpen: false,
            chooseMedium: { 
                item: null, 
                index: null, 
                dateItem: null, 
                dateIndex: null,
            },
        };
    },
    methods: {
        viewOneMedium(item) {
            if (this.mediumIds.indexOf(item.lineId) > -1) {
                return false;
            }
            this.mediumIds.push(item.lineId)
            this.changeMedium();
        },
        dragover(evt, dateItem, index, dateIndex) {
            //拖拽在这个div里面拖拽时
            this.evtChangeEndIndex = index
            this.evtChangeEndDateIndex = dateIndex
            this.evtChangeEndDate = dateItem.date
        },
        dragleave(evt, dateItem, index, dateIndex) {
            //当拖拽离开这个div时
            this.evtChangeEndIndex = index
            this.evtChangeEndDateIndex = dateIndex
            this.evtChangeEndDate = dateItem.date
        },
        dragstart(evt, dateItem, index, dateIndex) {
            //这是拖拽开始

            if (this.projectId != dateItem.projectList[0].projectId) {
                evt.preventDefault();
                return false;
            }
            this.evtChangeStartItem = JSON.parse(JSON.stringify(dateItem))
            this.evtChangeStartIndex = JSON.parse(JSON.stringify(index))
            this.$nextTick(() => {
                let num = this.evtChangeStartItem.projectList[0].startNum
                for (var i = 0; i < num; i++) {
                    this.dataOfflineShowList[this.evtChangeStartIndex].projectMsgDTOList[this.evtChangeStartItem.projectList[0].startIndex + i].hasChoose = false
                    this.dataOfflineShowList[this.evtChangeStartIndex].projectMsgDTOList[this.evtChangeStartItem.projectList[0].startIndex + i].projectList = []
                }
                this.dataOfflineShowList = JSON.parse(JSON.stringify(this.dataOfflineShowList))

                if(this.offlineMediumList && this.offlineMediumList.length > 0){
                    for (var i = 0; i < this.offlineMediumList.length; i++) {
                    for (var j = 0; j < this.offlineMediumList[i].dateList.length; j++) {
                        if (this.offlineMediumList[i].dateList[j].id == this.evtChangeStartItem.projectList[0].id) {
                            this.chooseTitleMediumIndex = i
                            break;
                        }
                    }
                }
                }
            })
        },
        dragend(evt, dateItem, index1, dateIndex1) {
            let item1 = this.dataOfflineShowList[this.evtChangeEndIndex]
            //这是拖拽结束
            let index = this.evtChangeEndIndex
            let dateIndex = this.evtChangeEndDateIndex
            let hasPut = false;
            // 判断是否超出对应媒体列表
            if (this.dataOfflineShowList[this.evtChangeEndIndex].id != this.evtChangeStartItem.projectList[0].lineId) {
                hasPut = true;
            }
            let num = this.evtChangeStartItem.projectList[0].startNum
            //如果num小于7，那么需要重新计算num的值，并且重新赋值
            let changeNumStatus = false;
            let endTime = 0;
            if (num < 7) {
                let putInCycle = this.evtChangeStartItem.projectList[0].putInCycle
                if (this.evtChangeStartItem.projectList[0].numTypeName == "周") {
                    let putInCycleNuma = putInCycle.substring(0, putInCycle.indexOf("周"))
                    let putInCycleNum1 = putInCycleNuma * 7 - 1
                    endTime = new Date(this.evtChangeEndDate).getTime() + putInCycleNum1 * 24 * 60 * 60 * 1000
                } else {
                    let putInCycleNuma = putInCycle.substring(0, putInCycle.indexOf("月"))
                    let putInCycleNum1 = putInCycleNuma
                    let nextMonth = new Date(this.evtChangeEndDate).getMonth() + putInCycleNum1;
                    endTime = new Date(new Date(this.evtChangeEndDate).getFullYear(), nextMonth, new Date(this.evtChangeEndDate).getDate()).getTime();
                }
                let startTime = new Date(this.evtChangeEndDate).getTime()
                const oneDay = 1000 * 60 * 60 * 24;
                let putInCycleNum = Math.round(Math.abs((endTime - startTime) / oneDay)) + 1
                num = putInCycleNum;
                changeNumStatus = true;
            }
            if (!hasPut) {
                // 判断拖拽的位置是否满足条件
                let list = this.dataOfflineShowList[index].projectMsgDTOList
                for (let i = 0; i < num; i++) {
                    if (list[dateIndex + i].hasChoose) {
                        hasPut = true;
                        break;
                    }
                }
            }
            if (!hasPut) {
                // 满足条件后的移动
                let projectMsg = this.evtChangeStartItem.projectList[0]
                projectMsg.date = this.evtChangeEndDate
                projectMsg.startIndex = this.evtChangeEndDateIndex
                projectMsg.chooseTime = new Date(this.evtChangeEndDate).getTime()
                projectMsg.key = projectMsg.lineId + "-" + projectMsg.date
                if (changeNumStatus) {
                    // 如果改变了num，那么需要重新计算结束时间
                    projectMsg.chooseEndTime = endTime
                    projectMsg.startNum = num
                }
                for (var i = 0; i < num; i++) {
                    this.dataOfflineShowList[index].projectMsgDTOList[dateIndex + i].hasChoose = true
                    this.dataOfflineShowList[index].projectMsgDTOList[dateIndex + i].projectList = [projectMsg]
                }
                this.dataOfflineShowList = JSON.parse(JSON.stringify(this.dataOfflineShowList))
                this.dragChangePost(item1)
            } else {
                this.$message({
                        type: 'warning',
                        message: '时间有冲突'
                    });
                for (var i = 0; i < this.evtChangeStartItem.projectList[0].startNum; i++) {
                    this.dataOfflineShowList[this.evtChangeStartIndex].projectMsgDTOList[this.evtChangeStartItem.projectList[0].startIndex + i].hasChoose = true
                    this.dataOfflineShowList[this.evtChangeStartIndex].projectMsgDTOList[this.evtChangeStartItem.projectList[0].startIndex + i].projectList = this.evtChangeStartItem.projectList
                }
                this.dataOfflineShowList = JSON.parse(JSON.stringify(this.dataOfflineShowList))
                
            }
        },
        dragChangePost(item) {
            const params = {
                token: this.$store.state.token,
                projectId: this.projectId,
                lineId: this.evtChangeStartItem.projectList[0].lineId,
                chooseTime: new Date(this.evtChangeStartItem.projectList[0].date).getTime(),
                chooseId: this.evtChangeStartItem.projectList[0].id,
                lineIndex:item.rank
            };
            if (this.endDayNum) {
                params.endDayNum = this.endDayNum - 1
            }
            params.areaType = item.areaType
                // 检查所有参数是否都有值
                const isValid = Object.values(params).every(value => {
                // 处理数字0的特殊情况，0是有效值
                if (typeof value === 'number') return true;
                // 处理布尔值
                if (typeof value === 'boolean') return true;
                // 处理其他类型，确保非空
                return value !== null && value !== undefined && value !== '';
            });
           
            APIProject.doSetProjectPackageTime(params).then((res) => {
                if (res.key === 1000) {
                    this.$message({
                        type: 'success',
                        message: '移动成功'
                    });
                    // this.showLoading = true;
                    this.$emit("refushPackageList");
                    let offIndex = null;
                    if(this.offlineMediumList && this.offlineMediumList.length > 0){
                        for (var i = 0; i < this.offlineMediumList.length; i++) {
                        this.offlineMediumList[i].dateList.forEach(item => {
                            if (item.id == this.evtChangeStartItem.projectList[0].id) {
                                item.chooseTime = this.evtChangeStartItem.projectList[0].chooseTime;
                                item.chooseEndTime = this.evtChangeStartItem.projectList[0].chooseEndTime;
                            }
                        })
                    }
                    }
                
                    // 处理offlineMediumList的开始时间与结束时间，并且排序
                    // eslint-disable-next-line vue/no-mutating-props
                    // this.offlineMediumList[this.chooseTitleMediumIndex].dateList.sort((a, b) => {
                    //     return a.chooseTime - b.chooseTime
                    // })
                    if (this.chooseTitleMediumIndex >= 0 && this.chooseTitleMediumIndex) {
                    const currentItem = this.offlineMediumList[this.chooseTitleMediumIndex];
                    if (currentItem && currentItem.dateList) {
                        currentItem.dateList.sort((a, b) => {
                            const timeA = a.chooseTime || 0;
                            const timeB = b.chooseTime || 0;
                            return timeA - timeB;
                        });
                    }
                }
                    let dateString = ""
                    if (this.chooseTitleMediumIndex >= 0 && this.chooseTitleMediumIndex){
                        this.offlineMediumList[this.chooseTitleMediumIndex].dateList.forEach(dateItem => {
                        if (dateItem.chooseTime && dateItem.chooseEndTime) {
                            dateString += this.formatterDate(dateItem.chooseTime) + "至" + this.formatterDate(dateItem.chooseEndTime) + "; "
                        }
                    })
                    }
                  
                    // eslint-disable-next-line vue/no-mutating-props
                      //  this.offlineMediumList[this.chooseTitleMediumIndex].dateString = dateString
                      if (this.offlineMediumList && Array.isArray(this.offlineMediumList) && this.chooseTitleMediumIndex >= 0 && this.chooseTitleMediumIndex < this.offlineMediumList.length) {
                        const currentItem = this.offlineMediumList[this.chooseTitleMediumIndex];
                        if (currentItem) {
                            currentItem.dateString = dateString;
                        }
                    } 

                    for (var i = 1; i < this.dataOfflineList.length; i++) {
                        if (this.dataOfflineList[i].id == this.evtChangeStartItem.projectList[0].lineId) {
                            let rank = this.dataOfflineList[i].rank
                            // eslint-disable-next-line vue/no-mutating-props
                            this.dataOfflineList[i].projectMsgDTOList = this.dataOfflineShowList[rank + 1].projectMsgDTOList
                        }
                    }

                    this.showLoading = false;
                    this.mediumChooseStatus = false;
                }
            });
        },
        drag(evt, dateItem, index, dateIndex) {
            //这是拖拽中
        },
        // evt 里面有两个值，一个 evt.added 和 evt.removed
        // 可以分别知道移动元素的 ID 和 删除元素的 ID
        change(evt) {
            console.log(evt, 'change...')
        },
        // start , end , add , update , sort , remove 得到的都差不多
        start(evt, dateItem, item) {
            this.drag = true
            console.log(evt, 'start...', dateItem, item)
        },
        unchoose(evt, dateItem, index, dateIndex) {
            console.log(evt, dateItem, index, dateIndex, 'unchoose...')
        },
        remove(evt) {
            console.log(evt, 'remove...')
        },
        add(evt) {
            console.log(evt, 'add...')
        },
        clone(evt, dateItem, index) {
            console.log(evt, 'clone...', dateItem, index)
        },
        update(evt) {
            console.log(evt, 'update...')
        },
        end(evt, dateItem, index, dateIndex) {
            console.log(evt, 'end....', dateItem, index, dateIndex)
            this.drag = true
            evt.item  // 可以知道拖动的本身
            evt.to    // 可以知道拖动的目标列表
            evt.from  // 可以知道之前的列表
            evt.oldIndex  // 可以知道拖动前的位置
            evt.newIndex  // 可以知道拖动后的位置
        },
        move(evt, originalEvent) {
            console.log(evt, 'move')
            console.log(originalEvent) // 鼠标位置
        },
        onContextmenu(event, item, index, dateItem, dateIndex) {
            if (this.$store.state.userInfo.role && (this.$store.state.userInfo.role.includes(40) || this.$store.state.userInfo.role.includes(55))){
                return false;
            }
            this.chooseItemLeftIndex = index
            this.chooseItemTopIndex = dateIndex
            let del = {
                label: "删除",
                onClick: () => {
                    this.chooseDateClickDel(item, index, dateItem, dateIndex);
                }
            }
            let sure1 = {
                label: "更改为审核中",
                onClick: () => {
                    this.chooseDateClickSure(item, index, dateItem, dateIndex,1);
                }
            }
            let sure2 = {
                label: "更改为暂定",
                onClick: () => {
                    this.chooseDateClickSure(item, index, dateItem, dateIndex,2);
                }
            }
            let sure3 = {
                label: "更改为未签",
                onClick: () => {
                    this.chooseDateClickSure(item, index, dateItem, dateIndex,3);
                }
            }
            let sure4 = {
                label: "更改为已签",
                onClick: () => {
                    this.chooseDateClickSure(item, index, dateItem, dateIndex,4);
                }
            }
            let sure5 = {
                label: "更改为确认",
                onClick: () => {
                    this.chooseDateClickSure(item, index, dateItem, dateIndex,5);
                }
            }
            let addProject = {
                label: "新增其他项目",
                onClick: () => {
                    this.addMediumOtherProject(item, index, dateItem, dateIndex);
                }
            }
            let chooseProjectButton = {
                label: "选择易货项目",
                onClick: () => {
                    this.chooseYiHuoProject(item, index, dateItem, dateIndex);
                }
            }
            let chooseMediumOtherProjectButton = {
                label: "选择其他项目",
                onClick: () => {
                    this.chooseMediumOtherProject(item, index, dateItem, dateIndex);
                }
            }
            let updateUserButton = {
                label: "修改排期人",
                onClick: () => {
                    this.chooseMediumUser(item, index, dateItem, dateIndex);
                }
            }
            let itemList = []
            // if (!dateItem || dateItem.projectList.length == 0) {
            //     if (this.operationList.includes("mediumOtherProject:addMediumOtherProject")) {
            //         itemList.push(addProject)
            //     }
            //     if (this.operationList.includes("project:view")) {
            //         itemList.push(chooseProjectButton)
            //     }
            //     if (this.operationList.includes("mediumOtherProject:view")) {
            //         itemList.push(chooseMediumOtherProjectButton)
            //     }
            // }
            if (dateItem && dateItem.projectList.length > 0) {
                if (dateItem.projectList[0] && dateItem.projectList[0].sureType){
                    if (dateItem.projectList[0].sureType != 1){
                        itemList.push(sure1)
                    }
                    if (dateItem.projectList[0].sureType != 2){
                        itemList.push(sure2)
                    }
                    if (dateItem.projectList[0].sureType != 3){
                        itemList.push(sure3)
                    }
                    if (dateItem.projectList[0].sureType != 4){
                        itemList.push(sure4)
                    }
                    if (dateItem.projectList[0].sureType != 5){
                        itemList.push(sure5)
                    }
                }
                itemList.push(del)
                if (this.operationList.includes("updateUser")) {
                    itemList.push(updateUserButton)
                }
            }
            if (!itemList || itemList.length == 0) {
                return false;
            }
            this.$contextmenu({
                items: itemList,
                event, // 鼠标事件信息
                customClass: "custom-class", // 自定义菜单 class
                zIndex: 9999, // 菜单样式 z-index
                minWidth: 130 // 主菜单最小宽度
            });
            return false;
        },
        closeChooseUser(){
            this.manageUserChooseOpen = false
        },
        getChooseUserId(row){
            const params = {
                token: this.$store.state.token,
                id: this.chooseMediumDateId,
                chooseUserId: row.id
            };
            APIMediumOtherProject.doUpdateMediumUser(params).then((res) => {
                if (res.key === 1000) {
                    this.$message({
                        type: 'success',
                        message: '修改成功'
                    });
                    this.manageUserChooseOpen = false
                    this.$emit("refushPackageList");
                    let index1 = this.chooseMedium.index
                    let item2 = this.chooseMedium.dateItem
                    let startNum = item2.projectList[0].startNum;
                    let startIndex = item2.projectList[0].startIndex;
                    for (var i = 0; i < startNum; i++) {
                        this.dataOfflineShowList[index1].projectMsgDTOList[startIndex + i].projectList[0].createUserId = row.id;
                        this.dataOfflineShowList[index1].projectMsgDTOList[startIndex + i].projectList[0].createUserName = row.username;
                    }
                }
            });
        },
        chooseMediumUser(item, index, dateItem, dateIndex) {
            // 选择排期人
            this.manageUserRoleIds = '50,51,59,60,61,62'
            this.manageUserChooseOpen = true
            this.chooseMediumDateId = dateItem.projectList[0].id
            this.chooseMedium = {
                item, index, dateItem, dateIndex
            }
        },
        chooseYiHuoProject(item, index, dateItem, dateIndex) {
            this.chooseProjectType = 2
            this.chooseProjectTitle = '选择易货项目'
            this.searchForm = {
                keyword: "",
                otherProjectType: null,
            }
            this.pageNum = 1;
            this.dataList = [];
            this.getYiHuoProjectPost();
            this.chooseMediumOtherProjectDialogVisible = true;
        },
        // 选择其他项目弹窗
        chooseMediumOtherProject(item, index, dateItem, dateIndex) {
            this.chooseProjectType = 3
            this.chooseProjectTitle = '选择其他项目'
            this.getSysLabel()
            this.searchForm = {
                keyword: "",
                otherProjectType: null,
            }
            this.pageNum = 1;
            this.dataList = [];
            this.getMediumOtherProjectPost();
            this.chooseMediumOtherProjectDialogVisible = true;
        },
        chooseMediumOtherProjectHandleClose() {
            this.chooseMediumOtherProjectDialogVisible = false;
        },
        // 提交选择的其他项目及时间
        commitChooseMediumProject() {
            let item1 = this.dataOfflineShowList[this.chooseItemLeftIndex]
            const params = {
                token: this.$store.state.token,
                addIndex: 1,
                lineId: item1.id,
                chooseTime: new Date(this.dataOfflineShowList[this.chooseItemLeftIndex].projectMsgDTOList[this.chooseItemTopIndex].date).getTime(),
                chooseId: this.chooseProjectId,
                chooseType: this.chooseProjectType,
                sureType: this.sureType,
                lineIndex:item1.rank
            };
            if(this.endDayNum){
                params.endDayNum = this.endDayNum - 1
            }
            params.areaType = item1.areaType
            APIMediumOtherProject.doAddMediumOtherProjectFromCal(params).then((res) => {
                if (res.key === 1000) {
                    this.$message({
                        type: 'success',
                        message: '添加成功'
                    });
                    this.$emit("refushPackageList");
                    let projectMediumId = res.result.data
                    let date = this.dataOfflineShowList[this.chooseItemLeftIndex].projectMsgDTOList[this.chooseItemTopIndex].date
                    let endTime = 0;
                    if (this.dataOfflineShowList[this.chooseItemLeftIndex].putInCycle.indexOf("周")) {
                        let putInCycle = this.dataOfflineShowList[this.chooseItemLeftIndex].putInCycle
                        let putInCycleNuma = putInCycle.substring(0, putInCycle.indexOf("周"))
                        let putInCycleNum1 = putInCycleNuma * 7 - 1
                        endTime = new Date(date).getTime() + putInCycleNum1 * 24 * 60 * 60 * 1000
                    } else {
                        let putInCycle = this.dataOfflineShowList[this.chooseItemLeftIndex].putInCycle
                        let putInCycleNuma = putInCycle.substring(0, putInCycle.indexOf("月"))
                        let putInCycleNum1 = putInCycleNuma
                        let nextMonth = new Date(date).getMonth() + putInCycleNum1;
                        endTime = new Date(new Date(date).getFullYear(), nextMonth, new Date(date).getDate()).getTime();
                    }
                    if (this.endDayNum){
                        endTime = new Date(date).getTime() + (this.endDayNum - 1) * 24 * 60 * 60 * 1000
                    }
                    let startTime = new Date(date).getTime()
                    const oneDay = 1000 * 60 * 60 * 24;
                    let putInCycleNum = Math.round(Math.abs((endTime - startTime) / oneDay)) + 1
                    let obj = {
                        brands: this.chooseBrands,
                        projectName: this.chooseProjectName,
                        chooseTime: new Date(startTime).getTime(),
                        chooseEndTime: new Date(endTime).getTime(),
                        day: date,
                        date: date,
                        dayTime: new Date(date).getTime(),
                        hasJoin: true,
                        key: this.dataOfflineShowList[this.chooseItemLeftIndex].id + "-" + date,
                        lineId: this.dataOfflineShowList[this.chooseItemLeftIndex].id,
                        numTypeHame: 1,
                        putInCycle: this.dataOfflineShowList[this.chooseItemLeftIndex].putInCycle,
                        startIndex: this.chooseItemTopIndex,
                        startNum: putInCycleNum,
                        id: projectMediumId,
                        sureType: this.sureType,
                        createUserName: this.userInfo.username,
                        createUserId: this.userInfo.userId,
                    }
                    for (var i = 0; i < putInCycleNum; i++) {
                        this.dataOfflineShowList[this.chooseItemLeftIndex].projectMsgDTOList[this.chooseItemTopIndex + i].hasChoose = true
                        this.dataOfflineShowList[this.chooseItemLeftIndex].projectMsgDTOList[this.chooseItemTopIndex + i].projectList.push(obj)
                    }
                    this.showLoading = false;
                    this.chooseMediumOtherProjectDialogVisible = false;
                }
            });
        },
        chooseDateClickSure(item1, index1, item2, index2,sureType) {
            const params = {
                token: this.$store.state.token,
                chooseId: item2.projectList[0].id,
                sureType:sureType
            };
            APIMediumOtherProject.doSureMediumOtherProject(params).then((res) => {
                if (res.key === 1000) {
                    this.$message({
                        type: 'success',
                        message: '确认成功'
                    });
                    this.$emit("refushPackageList");
                    let startNum = item2.projectList[0].startNum;
                    let startIndex = item2.projectList[0].startIndex;
                    for (var i = 0; i < startNum; i++) {
                        this.dataOfflineShowList[index1].projectMsgDTOList[startIndex + i].projectList[0].sureType = sureType;
                    }
                    for (var i = 1; i < this.dataOfflineList.length; i++) {
                        if (this.dataOfflineList[i].id == item1.lineId) {
                            let rank = this.dataOfflineList[i].rank
                            // eslint-disable-next-line vue/no-mutating-props
                            // this.dataOfflineList[i].projectMsgDTOList = this.dataOfflineShowList[rank + 1].projectMsgDTOList
                        }
                    }
                    this.showLoading = false;
                }
            });
        },
        chooseDateClickDel(item1, index1, item2, index2) {
            // if(!this.calendarShowType || this.calendarShowType != 2){
            //     return;
            // }
            // if(this.projectId != item2.projectList[0].projectId){
            //     this.$message({
            //         type: 'error',
            //         message: '无法删除该项目以外的其他项目'
            //     });
            //     return;
            // }
            // const params = {
            //     token: this.$store.state.token,
            //     projectId: this.dataOfflineShowList[this.chooseItemLeftIndex].projectMsgDTOList[this.chooseItemTopIndex].projectList[0].id,
            //     addIndex: 1,
            //     lineId: item1.id,
            //     chooseTime: null,
            //     chooseId: item2.projectList[0].id,
            // };
            // if (this.endDayNum){
            //     params.endDayNum = this.endDayNum - 1
            // }

            const params ={
                id:item2.projectList[0].id
            }
            APIProject.doDelProjectMedium(params).then((res) => {   // doSetProjectPackageTime
                if (res.key === 1000) {
                    this.$message({
                        type: 'success',
                        message: '删除成功'
                    });
                    this.$emit("refushPackageList");
                    let chooseTitleMediumIndex = null;
                    if (this.offlineMediumList) {
                        for (var i = 0; i < this.offlineMediumList.length; i++) {
                            for (var j = 0; j < this.offlineMediumList[i].dateList.length; j++) {
                                if (this.offlineMediumList[i].dateList[j].id == item2.projectList[0].id) {
                                    chooseTitleMediumIndex = i
                                    // eslint-disable-next-line vue/no-mutating-props
                                    this.offlineMediumList[i].dateList[j].chooseTime = null
                                    // eslint-disable-next-line vue/no-mutating-props
                                    this.offlineMediumList[i].dateList[j].chooseEndTime = null
                                    break;
                                }
                            }
                        }
                        // 处理开始时间与结束时间，并且排序
                        let dateString = ""
                        this.offlineMediumList[chooseTitleMediumIndex].dateList.forEach(dateItem => {
                            if (dateItem.chooseTime && dateItem.chooseEndTime) {
                                dateString += this.formatterDate(dateItem.chooseTime) + "至" + this.formatterDate(dateItem.chooseEndTime) + "; "
                            }
                        })
                        // eslint-disable-next-line vue/no-mutating-props
                        this.offlineMediumList[chooseTitleMediumIndex].dateString = dateString
                        // eslint-disable-next-line vue/no-mutating-props
                        this.offlineMediumList[chooseTitleMediumIndex].hasJoinNum = this.offlineMediumList[chooseTitleMediumIndex].hasJoinNum ? this.offlineMediumList[chooseTitleMediumIndex].hasJoinNum + 1 : 1
                    }
                    let startNum = item2.projectList[0].startNum;
                    let startIndex = item2.projectList[0].startIndex;
                    for (var i = 0; i < startNum; i++) {
                        this.dataOfflineShowList[index1].projectMsgDTOList[startIndex + i].hasChoose = false;
                        this.dataOfflineShowList[index1].projectMsgDTOList[startIndex + i].projectList = [];
                    }
                    for (var i = 1; i < this.dataOfflineList.length; i++) {
                        if (this.dataOfflineList[i].id == item1.lineId) {
                            let rank = this.dataOfflineList[i].rank
                            // eslint-disable-next-line vue/no-mutating-props
                            this.dataOfflineList[i].projectMsgDTOList = this.dataOfflineShowList[rank + 1].projectMsgDTOList
                        }
                    }
                    this.showLoading = false;
                }
            });
        },
        show(val) {
        },
        chooseMediumTime(item, index) {
            this.chooseTitleMediumIndex = index;
            this.mediumIds = [item.lineId]
            this.changeMedium();
            this.mediumChooseStatus = true;
            this.chooseId = null;
            // if(item.chooseTime){
            //     this.chooseId = item.id
            // }
        },
        chooseDateClick(item1, index1, item2, index2) {
            if (!this.showButtonType || this.showButtonType != 3){
                if (item2.projectList && item2.projectList.length > 0){
                    let projectMsg = item2.projectList[0]
                    this.$emit("getOneProjectPackageListMsg", projectMsg.projectId, projectMsg.projectType == 1 ? 2 : 3, projectMsg.brands)
                }
            }else{
                this.chooseItemLeftIndex = index1
                this.chooseItemTopIndex = index2
                this.chooseProjectId = this.chooseProjectMsg.id
                this.chooseProjectType = this.chooseProjectMsg.projectType == 1 ? 2 : 3
                this.chooseBrands = this.chooseProjectMsg.brands
                this.chooseProjectName = this.chooseProjectMsg.projectName
                this.commitChooseMediumProject()
            }
            return
            if (!this.mediumChooseStatus) {
                return;
            }
            if (!this.calendarShowType || this.calendarShowType != 2) {
                return;
            }
            if (item2.hasChoose) {
                this.$message({
                    type: 'info',
                    message: '该日期已选择'
                });
                return;
            }
            let endTime = 0;
            if (this.offlineMediumList[this.chooseTitleMediumIndex].numTypeName == "周") {
                let putInCycle = this.offlineMediumList[this.chooseTitleMediumIndex].putInCycle
                let putInCycleNuma = putInCycle.substring(0, putInCycle.indexOf("周"))
                let putInCycleNum1 = putInCycleNuma * 7 - 1
                endTime = new Date(item2.date).getTime() + putInCycleNum1 * 24 * 60 * 60 * 1000
            } else {
                let putInCycle = this.offlineMediumList[this.chooseTitleMediumIndex].putInCycle
                let putInCycleNuma = putInCycle.substring(0, putInCycle.indexOf("月"))
                let putInCycleNum1 = putInCycleNuma
                let nextMonth = new Date(item2.date).getMonth() + putInCycleNum1;
                endTime = new Date(new Date(item2.date).getFullYear(), nextMonth, new Date(item2.date).getDate()).getTime();
            }
            let startTime = new Date(item2.date).getTime()
            const oneDay = 1000 * 60 * 60 * 24;
            let putInCycleNum = Math.round(Math.abs((endTime - startTime) / oneDay)) + 1
            let hasChooseStatus = false;
            for (var i = 0; i < putInCycleNum; i++) {
                if (this.dataOfflineShowList[index1].projectMsgDTOList[index2 + i].hasChoose) {
                    hasChooseStatus = true;
                    this.$message({
                        type: 'info',
                        message: '该日期无法选择，请重新选择日期'
                    });
                    return;
                }
            }
            if (hasChooseStatus) {
                this.$message({
                    type: 'info',
                    message: '该日期无法选择，请重新选择日期'
                });
                return;
            }

            const params = {
                token: this.$store.state.token,
                projectId: this.projectId,
                addIndex: this.chooseShowAddIndex,
                lineId: item1.id,
                chooseTime: new Date(item2.date).getTime(),
            };
            APIProject.doSetProjectPackageTime(params).then((res) => {
                if (res.key === 1000) {
                    this.$message({
                        type: 'success',
                        message: '选择成功'
                    });
                    // this.showLoading = true;
                    this.$emit("refushPackageList");
                    // eslint-disable-next-line vue/no-mutating-props
                    this.offlineMediumList[this.chooseTitleMediumIndex].dateList.push({
                        chooseTime: new Date(item2.date).getTime(),
                        chooseEndTime: endTime,
                    })
                    // 处理开始时间与结束时间，并且排序
                    // eslint-disable-next-line vue/no-mutating-props
                    this.offlineMediumList[this.chooseTitleMediumIndex].dateList.sort((a, b) => {
                        return a.chooseTime - b.chooseTime
                    })
                    let dateString = ""
                    this.offlineMediumList[this.chooseTitleMediumIndex].dateList.forEach(dateItem => {
                        if (dateItem.chooseTime && dateItem.chooseEndTime) {
                            dateString += this.formatterDate(dateItem.chooseTime) + "至" + this.formatterDate(dateItem.chooseEndTime) + "; "
                        }
                    })
                    // eslint-disable-next-line vue/no-mutating-props
                    this.offlineMediumList[this.chooseTitleMediumIndex].dateString = dateString
                    // eslint-disable-next-line vue/no-mutating-props
                    this.offlineMediumList[this.chooseTitleMediumIndex].hasJoinNum = this.offlineMediumList[this.chooseTitleMediumIndex].hasJoinNum - 1 >= 0 ? this.offlineMediumList[this.chooseTitleMediumIndex].hasJoinNum - 1 : 0

                    let obj = {
                        brands: this.brands,
                        chooseEndTime: endTime,
                        chooseTime: startTime,
                        date: item2.date,
                        day: item2.date,
                        dayTime: new Date(item2.date).getTime(),
                        hasJoin: true,
                        id: this.offlineMediumList[this.chooseTitleMediumIndex].id,
                        key: this.offlineMediumList[this.chooseTitleMediumIndex].lineId + "-" + item2.date,
                        lineId: this.offlineMediumList[this.chooseTitleMediumIndex].lineId,
                        numTypeName: this.offlineMediumList[this.chooseTitleMediumIndex].numTypeName,
                        projectId: this.projectId,
                        projectName: this.projectName,
                        startIndex: index2,
                        startNum: putInCycleNum,
                    }
                    for (var i = 0; i < putInCycleNum; i++) {
                        this.dataOfflineShowList[index1].projectMsgDTOList[index2 + i].hasChoose = true
                        this.dataOfflineShowList[index1].projectMsgDTOList[index2 + i].projectList = [obj]
                    }
                    for (var i = 1; i < this.dataOfflineList.length; i++) {
                        if (this.dataOfflineList[i].id == this.offlineMediumList[this.chooseTitleMediumIndex].lineId) {
                            let rank = this.dataOfflineList[i].rank
                            // eslint-disable-next-line vue/no-mutating-props
                            this.dataOfflineList[i].projectMsgDTOList = this.dataOfflineShowList[rank + 1].projectMsgDTOList
                        }
                    }
                    if (this.offlineMediumList[this.chooseTitleMediumIndex].hasJoinNum == 0) {
                        this.mediumChooseStatus = false;
                    }
                    this.showLoading = false;
                }
            });
        },
        hoverDateItem(val) {
        },
        changeMedium() {
            if (this.mediumIds && this.mediumIds.length > 0) {
                let obj = { name: "" };
                let list = [];
                this.mediumIds.forEach(mediumItem => {
                    list = list.concat(this.dataOfflineList.filter(item => item.id == mediumItem))
                })
                this.dataOfflineShowList = [obj].concat(list);
            } else {
                this.dataOfflineShowList = this.dataOfflineList;
            }
        },
        windowScrollEnd(event) {
            let a = event.target;
            let b = Math.ceil(a.scrollWidth - a.clientWidth - a.scrollLeft);
            if (this.loading) {
                return;
            }
            if (b < 50) {
                this.loading = true;
                this.evtChangeStartItem = {}
                this.evtChangeStartIndex = null
                this.scrollStatusType = 3
                this.$emit("scrollEndCalendar", this.dateList[this.dateList.length - 1]);
            }
            if (a.scrollLeft == 0) {
                // this.loading = true;
                this.evtChangeStartItem = {}
                this.evtChangeStartIndex = null
                this.scrollStatusType = 2
                this.$emit("scrollStartCalendar", this.dateList[1]);
            }
            
       
        },
        // 第三种方案
        getChooseDate() {
            if (this.dateList && this.dateList.length > 0 && this.dataOfflineList && this.dataOfflineList.length > 0) {
                let dateList = JSON.parse(JSON.stringify(this.dateList));
                dateList.splice(0, 1);
                let mediumMap = {};
                let mediumList = [];
                let dateProjectShowList = []
                dateList.forEach((item2, dateIndex) => {
                    let obj = {
                        projectList: [],
                        dateIndex: 0,
                        hasChoose: false,
                        date: item2.date,
                    };
                    dateProjectShowList.push(obj);
                });
                // 塞入项目列表模块
                this.dataOfflineList.forEach(item => {
                    item.projectMsgDTOList = JSON.parse(JSON.stringify(dateProjectShowList))
                })
                let aList = JSON.parse(JSON.stringify(this.dataOfflineList))
                for (let i = 0; i < aList.length; i++) {
                    if (aList[i] && aList[i].id) {
                        if (!mediumMap[aList[i].id]) {
                            mediumMap[aList[i].id] = aList[i];
                            mediumList.push({ id: aList[i].id, name: aList[i].name })
                        }
                    }
                }
                let chooseMap = JSON.parse(JSON.stringify(this.projectChooseMap))
                let chooseAddDateList = []
                if (Object.keys(chooseMap).length > 0) {
                    chooseAddDateList = Object.keys(chooseMap).map(function (t) {
                        chooseMap[t].forEach(item => {
                            item.key = t;
                        })
                        return chooseMap[t];
                    });
                }
                console.log("chooseAddDateList======", JSON.parse(JSON.stringify(chooseAddDateList)))
                let chooseList = []
                if (!this.calendarStartTimeShow) {
                    this.calendarStartTimeShow = this.calendarStartTime
                }
                if (!this.calendarEndTimeShow) {
                    this.calendarEndTimeShow = this.calendarEndTime
                }
                // 所有有数据的天数集合
                if (chooseAddDateList.length > 0) {
                    chooseAddDateList.forEach(chooseItem => {
                        chooseItem.forEach((item, index) => {
                            // 左滑后处理开始时间，右滑后处理结束时间
                            // let startTime = item.chooseTime
                            // let endTime = item.chooseEndTime
                            let startTime = this.calendarStartTimeShow > item.chooseTime ? this.calendarStartTimeShow : item.chooseTime
                            let endTime = this.calendarEndTimeShow < item.chooseEndTime ? this.calendarEndTimeShow : item.chooseEndTime
                            const oneDay = 1000 * 60 * 60 * 24;
                            let putInCycleNum = Math.round(Math.abs((endTime - startTime) / oneDay)) + 1
                            let d = JSON.parse(JSON.stringify(item))
                            d.dayTime = startTime
                            d.day = this.formatterDate(d.dayTime)
                            d.startNum = putInCycleNum;
                            d.hasJoin = false;
                            chooseList.push(d)
                        })
                    })
                }
                let bList = JSON.parse(JSON.stringify(aList))
                for (let i = 0; i < bList.length; i++) {
                    if (bList[i].id) {
                        for (var j = 0; j < bList[i].projectMsgDTOList.length; j++) {
                            bList[i].projectMsgDTOList[j].hasChoose = false;
                            bList[i].projectMsgDTOList[j].projectList = [];
                        }
                    }
                }
                // 把数据渲染进入列表
                for (let z = 0; z < chooseList.length; z++) {
                    let item = chooseList[z]
                    for (let i = 0; i < bList.length; i++) {
                        if (bList[i].id) {
                            if (bList[i].id == item.lineId && bList[i].rank == item.lineIndex && bList[i].areaType == item.areaType){
                                for (var j = 0; j < bList[i].projectMsgDTOList.length; j++) {
                                    if (item.day == bList[i].projectMsgDTOList[j].date){
                                        if (!bList[i].projectMsgDTOList[j].hasChoose) {
                                            // 当前方块中没有选中的数据
                                            for (let n = 0; n < item.startNum; n++) {
                                                if (j + n < bList[i].projectMsgDTOList.length) {
                                                    bList[i].projectMsgDTOList[j + n].hasChoose = true;
                                                    item.startIndex = j;
                                                    bList[i].projectMsgDTOList[j + n].projectList = [item]
                                                }
                                            }
                                            item.hasJoin = true;
                                        }else{
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                // for (let i = 0; i < bList.length; i++) {
                //     if (bList[i].id) {
                //         for (var j = 0; j < bList[i].projectMsgDTOList.length; j++) {
                //             for (let z = 0; z < chooseList.length; z++) {
                //                 let item = chooseList[z]
                //                 for (var b = 0; b < bList[i].num; b++) {
                //                     if (!item.hasJoin && bList[i + b] && bList[i + b].id && item.lineId == bList[i + b].id && item.day == bList[i + b].projectMsgDTOList[j].date) {
                //                         if (!bList[i + b].projectMsgDTOList[j].hasChoose){
                //                             // 当前方块中没有选中的数据
                //                             for (let n = 0; n < item.startNum; n++) {
                //                                 if (j + n >= bList[i + b].projectMsgDTOList.length) {
                //                                     break;
                //                                 }
                //                                 bList[i + b].projectMsgDTOList[j + n].hasChoose = true;
                //                                 item.startIndex = j;
                //                                 bList[i + b].projectMsgDTOList[j + n].projectList = [item]
                //                             }
                //                             item.hasJoin = true;
                //                         } else {
                //                             break;
                //                             // 当前方块中存在选中的数据
                //                             // if (!bList[i + b + 1].projectMsgDTOList[j].hasChoose) {
                //                             //     if (bList[i + b + 1] && bList[i].id == bList[i + b + 1].id) {
                //                             //         for (let n = 0; n < item.startNum; n++) {
                //                             //             if (j + n >= bList[i + b + 1].projectMsgDTOList.length) {
                //                             //                 break;
                //                             //             }
                //                             //             bList[i + b + 1].projectMsgDTOList[j + n].hasChoose = true;
                //                             //             item.startIndex = j;
                //                             //             bList[i + b + 1].projectMsgDTOList[j + n].projectList = [item]
                //                             //         }
                //                             //         item.hasJoin = true;
                //                             //         if (bList[i].id == 27) {
                //                             //             console.log("------2")
                //                             //         }
                //                             //     }
                //                             // }
                //                         }
                //                     }
                //                 }
                //             }
                //         }
                //     }
                // }
                this.modelList = bList;
                for (var i = 0; i < this.dataOfflineList.length; i++) {
                    // eslint-disable-next-line vue/no-mutating-props
                    this.dataOfflineList[i].projectMsgDTOList = bList[i].projectMsgDTOList
                }
                this.mediumList = mediumList;
                setTimeout(() => {
                    this.changeMedium()
                }, 100);
                this.dataOfflineShowList = this.dataOfflineList;
                this.loading = false;
            }
        },
        getHasPutList(aList, idsList, otherList) {
            let aNum = 1;
            let otherNum = 0;
            let anotherList = []
            for (let i = 0; i < aList.length; i++) {
                for (var j = 0; j < aList[i].projectMsgDTOList.length; j++) {
                    for (var z = 0; z < otherList.length; z++) {
                        let mapList = otherList[z]
                        if (aList[i].projectMsgDTOList[j] && aList[i].projectMsgDTOList[j].date && aList[i].projectMsgDTOList[j].date == mapList.date && !aList[i].projectMsgDTOList[j].hasChoose) {
                            if ((aList[i].rank > -1) && mapList) {
                                let aStartTime = new Date(mapList.chooseTime)
                                let aEndTime = new Date(mapList.chooseEndTime)
                                const oneDay = 1000 * 60 * 60 * 24;
                                let putInCycleNum = Math.round(Math.abs((aEndTime - aStartTime) / oneDay))
                                // 计算出单个项目的排期周期
                                let hasPut = 1;
                                let hasIndex = i;
                                for (let n = 0; n < putInCycleNum; n++) {
                                    if (aList[i].projectMsgDTOList[j + n].hasChoose) {
                                        hasPut = 2;
                                    }
                                }
                                if (hasPut == 2) {
                                    let aResult = this.getHasPut(aList)
                                    if (aResult) {
                                        aNum = aNum + 1;
                                    }
                                    hasIndex = aNum;
                                }
                                if (aList[hasIndex].id == aList[i].id) {
                                    for (let n = 0; n < putInCycleNum; n++) {
                                        if (!aList[hasIndex].projectMsgDTOList[j + n].hasChoose) {
                                            idsList.push({
                                                i: hasIndex,
                                                j: j,
                                                n: n,
                                                projectList: [mapList]
                                            })
                                            mapList.startIndex = j
                                            mapList.startNum = putInCycleNum
                                            aList[hasIndex].projectMsgDTOList[j + n].projectList = [mapList];
                                            aList[hasIndex].projectMsgDTOList[j + n].hasChoose = true;
                                        }
                                    }
                                } else {
                                    otherNum = otherNum + 1;
                                    anotherList.push(mapList)
                                }
                            }
                        }
                    }
                }
            }
            if (otherNum > 0) {
                for (let i = 0; i < otherNum; i++) {
                    // let {aList,idsList} = this.getHasPutList(aList, idsList)
                    this.getHasPutList(aList, idsList, anotherList)
                }
            }
            return { aList, idsList };
        },
        getHasPut(aList) {
            let returnHasPut = false;
            for (let i = 0; i < aList.length; i++) {
                for (var j = 0; j < aList[i].projectMsgDTOList.length; j++) {
                    if (aList[i].projectMsgDTOList[j] && aList[i].projectMsgDTOList[j].date && this.projectChooseMap[aList[i].id + '-' + aList[i].projectMsgDTOList[j].date] && this.projectChooseMap[aList[i].id + '-' + aList[i].projectMsgDTOList[j].date].length > 0) {
                        let mapList = this.projectChooseMap[aList[i].id + '-' + aList[i].projectMsgDTOList[j].date]
                        if ((aList[i].rank > -1) && mapList[aList[i].rank]) {
                            let aStartTime = new Date(mapList[aList[i].rank].chooseTime)
                            let aEndTime = new Date(mapList[aList[i].rank].chooseEndTime)
                            const oneDay = 1000 * 60 * 60 * 24;
                            let putInCycleNum = Math.round(Math.abs((aEndTime - aStartTime) / oneDay))
                            // 计算出单个项目的排期周期
                            let hasPut = 1;
                            for (let n = 0; n < putInCycleNum; n++) {
                                if (aList[i].projectMsgDTOList[j + n].hasChoose) {
                                    hasPut = 2;
                                }
                            }
                            if (hasPut == 2) {
                                returnHasPut = true
                                return returnHasPut;
                            }
                        }
                    }
                }
            }
            return returnHasPut;
        },
      
        getDate() {
            let a = this.calendarStartTime;
            let b = this.calendarEndTime;
            if (a === b) {
                return
            }
            let num = b - a;
            num /= (1000 * 60 * 60 * 24);
            this.getDateList(this.formatterTime(this.calendarStartTime), num);
        },
        getDateList(day, num) {
            let list = [];
            if (this.dateList && this.dateList.length > 0) {
                list = JSON.parse(JSON.stringify(this.dateList));
                list.shift();  // 去掉第一个元素
            }
            let showList = [];
            let finalList = []
            for (let i = 0; i < num; i++) {
                let date = this.formatterDate(day);
                let dateTime = new Date(date).getTime();
                // 获取星期信息
                let week = ['日', '一', '二', '三', '四', '五', '六'][new Date(date).getDay()];
                showList.push({
                    date: date,
                    dateTime: dateTime,
                    week: week // 添加星期信息到对象中
                });
                day = this.$moment(day).add(1, "day").format("YYYY-MM-DD");
            }
            let currentDate = new Date()
            let chooosedmouth = localStorage.getItem('choosedmouth');
            if (chooosedmouth) {
                const timestamp = parseInt(chooosedmouth, 10);
                currentDate = new Date(timestamp);
            }
            if (this.calendarStartTime && this.calendarEndTime && this.calendarStartTime < currentDate.getTime()) {
                if (list && list.length > 0) {
                    finalList = showList.concat(list);
                } else {
                    finalList = showList;
                }
            } else {
                if (showList && showList.length > 0) {
                    finalList = list.concat(showList);
                } else {
                    finalList = list;
                }
            }
            let showFinalDateMap = {}
            finalList.forEach(item => {
                showFinalDateMap[item.date] = item
            })
            let showFinalDateList = [];
            for (const key in showFinalDateMap) {
                if (showFinalDateMap.hasOwnProperty(key)) {
                    showFinalDateList.push(showFinalDateMap[key]);
                }
            }
            let obj = {
                date: '线下媒体',
            };
            let dateList = [obj].concat(showFinalDateList);
            this.dateList = dateList
        },
        formatterDate(time) {
            return this.$moment(time).format("YYYY-MM-DD");
        },
        formatterTime(time) {
            return this.$moment(time).format("YYYY-MM-DD HH:mm:ss");
        },
        getSysLabel() {
            this.$bus.$emit("show-loading", true);
            const params = {
                token: this.$store.state.token,
                sysLabelIds: '43',
            };
            APISysLabel.getSysLabelValueManageList(params).then((res) => {
                if (res.key === 1000) {
                    this.otherProjectTypeList = res.result.data[43];
                }
                this.$bus.$emit("show-loading", false);
            });
        },
        addMediumOtherProjectSubmit() {
            this.$refs['addMediumOtherProjectForm'].validate((valid) => {
                if (valid) {
                    this.$bus.$emit("show-loading", true);
                    const params = this.addMediumOtherProjectForm;
                    params.chooseType = 3
                    params.sureType = this.sureType
                    params.chooseTime = new Date(this.dataOfflineShowList[this.chooseItemLeftIndex].projectMsgDTOList[this.chooseItemTopIndex].date).getTime()
                    params.lineId = this.dataOfflineShowList[this.chooseItemLeftIndex].id
                    params.lineIndex = this.dataOfflineShowList[this.chooseItemLeftIndex].rank
                    params.areaType = this.dataOfflineShowList[this.chooseItemLeftIndex].areaType
                    APIMediumOtherProject.doAddMediumOtherProjectFromCal(params).then((res) => {
                        if (res.key === 1000) {
                            this.$message({
                                message: '提交成功',
                                type: 'success'
                            });
                            let projectMediumId = res.result.data
                            let date = this.dataOfflineShowList[this.chooseItemLeftIndex].projectMsgDTOList[this.chooseItemTopIndex].date
                            let endTime = 0;
                            if (this.dataOfflineShowList[this.chooseItemLeftIndex].putInCycle.indexOf("周")) {
                                let putInCycle = this.dataOfflineShowList[this.chooseItemLeftIndex].putInCycle
                                let putInCycleNuma = putInCycle.substring(0, putInCycle.indexOf("周"))
                                let putInCycleNum1 = putInCycleNuma * 7 - 1
                                endTime = new Date(date).getTime() + putInCycleNum1 * 24 * 60 * 60 * 1000
                            } else {
                                let putInCycle = this.dataOfflineShowList[this.chooseItemLeftIndex].putInCycle
                                let putInCycleNuma = putInCycle.substring(0, putInCycle.indexOf("月"))
                                let putInCycleNum1 = putInCycleNuma
                                let nextMonth = new Date(date).getMonth() + putInCycleNum1;
                                endTime = new Date(new Date(date).getFullYear(), nextMonth, new Date(date).getDate()).getTime();
                            }
                            if (this.endDayNum) {
                                endTime = new Date(date).getTime() + (this.endDayNum - 1) * 24 * 60 * 60 * 1000
                            }
                            let startTime = new Date(date).getTime()
                            const oneDay = 1000 * 60 * 60 * 24;
                            let putInCycleNum = Math.round(Math.abs((endTime - startTime) / oneDay)) + 1
                            let obj = {
                                brands: this.addMediumOtherProjectForm.brands,
                                projectName: this.addMediumOtherProjectForm.projectName,
                                chooseTime: new Date(startTime).getTime(),
                                chooseEndTime: new Date(endTime).getTime(),
                                day: date,
                                date: date,
                                dayTime: new Date(date).getTime(),
                                hasJoin: true,
                                key: this.dataOfflineShowList[this.chooseItemLeftIndex].id + "-" + date,
                                lineId: this.dataOfflineShowList[this.chooseItemLeftIndex].id,
                                numTypeHame: 1,
                                putInCycle: this.dataOfflineShowList[this.chooseItemLeftIndex].putInCycle,
                                startIndex: this.chooseItemTopIndex,
                                startNum: putInCycleNum,
                                id: projectMediumId,
                                sureType: this.sureType,
                                createUserName: this.userInfo.username,
                                createUserId: this.userInfo.userId,
                            }
                            for (var i = 0; i < putInCycleNum; i++) {
                                this.dataOfflineShowList[this.chooseItemLeftIndex].projectMsgDTOList[this.chooseItemTopIndex + i].hasChoose = true
                                this.dataOfflineShowList[this.chooseItemLeftIndex].projectMsgDTOList[this.chooseItemTopIndex + i].projectList.push(obj)
                            }
                            this.addMediumOtherProjectDialogVisible = false;
                        }
                        this.$bus.$emit("show-loading", false);
                    });
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        addMediumOtherProjectHandleClose() {
            this.addMediumOtherProjectDialogVisible = false;
        },
        addMediumOtherProject(item, index, dateItem, dateIndex) {
            this.formTitle = "新增其他项目";
            this.getSysLabel()
            this.addMediumOtherProjectForm = {
                id: null,
                projectName: '',
                otherProjectType: null,
                brands: '',
            };
            this.chooseItemLeftIndex = index
            this.chooseItemTopIndex = dateIndex
            this.addMediumOtherProjectDialogVisible = true;
        },
        // 分页pageSize改变
        handleSizeChange(e) {
            this.pageSize = e;
            this.reProjectPosts();
        },
        // 分页pageNum改变
        handleCurrentChange(e) {
            this.pageNum = e;
            if (this.chooseProjectType == 3) {
                this.getMediumOtherProjectPost();
            } else {
                this.getYiHuoProjectPost()
            }
        },
        // 重新请求
        reProjectPosts() {
            this.pageNum = 1;
            this.dataList = [];
            if (this.chooseProjectType == 3) {
                this.getMediumOtherProjectPost();
            } else {
                this.getYiHuoProjectPost()
            }
        },
        getYiHuoProjectPost() {
            this.$bus.$emit("show-loading", true);
            const params = {
                token: this.$store.state.token,
                pageNum: this.pageNum,
                pageSize: this.pageSize
            };
            if (this.searchForm.keyword) {
                params.keyword = this.searchForm.keyword;
            }
            APIProject.getProjectManageList(params).then((res) => {
                if (res.key === 1000) {
                    this.total = res.result.count;
                    res = res.result.list;
                    res.forEach(item => {
                        if (item.createTime) {
                            item.createDate = this.$moment(item.createTime).format("YYYY-MM-DD HH:mm");
                        }
                    })
                    this.dataList = res;
                }
                this.$bus.$emit("show-loading", false);
            });
        },
        getMediumOtherProjectPost() {
            this.$bus.$emit("show-loading", true);
            const params = {
                token: this.$store.state.token,
                pageNum: this.pageNum,
                pageSize: this.pageSize
            };
            if (this.searchForm.keyword) {
                params.keyword = this.searchForm.keyword;
            }
            if (this.searchForm.otherProjectType) {
                params.otherProjectType = this.searchForm.otherProjectType;
            }
            APIMediumOtherProject.getMediumOtherProjectList(params).then((res) => {
                if (res.key === 1000) {
                    this.total = res.result.count;
                    res = res.result.list;
                    res.forEach(item => {
                        if (item.createTime) {
                            item.createDate = this.$moment(item.createTime).format("YYYY-MM-DD HH:mm");
                        }
                    })
                    this.dataList = res;
                }
                this.$bus.$emit("show-loading", false);
            });
        },
        handleCurrentChangeTable(val, oldVal) {
            this.chooseProjectId = val.id
            this.chooseProjectName = val.projectName
            this.chooseBrands = val.brands
        },

        handleWheel(event) {
            const html = document.querySelector(".calendar-body-content-body");
            if (event.shiftKey) {
                html.scrollTop += event.deltaY;
                event.preventDefault();
            }
        },

    
        // handleScroll(event) {
        //     console.log(event)
        //     let html = document.querySelector(".calendar-body");
        //     let bodyBox = document.querySelector('.body-box');
        //     // const fixedHeader = document.querySelector('.fixed-header');
        //     // if (bodyBox.scrollTop > 0) {
        //     //     fixedHeader.style.position = 'sticky';
        //     //     fixedHeader.style.top = '0';
        //     //     fixedHeader.style.zIndex = '1';
        //     // } else {
        //     //     fixedHeader.style.position = 'static';
        //     // }
        // },
    }
};
</script>
<style>
.custom-class .menu_item__available:hover,
.custom-class .menu_item_expand {
    background: #ffecf2 !important;
    color: #ff4050 !important;
}
</style>
<style scoped>
.calendar-body-content-header {
    display: inline-flex;
    /* width: 100%; */
    /* height: auto; */
}

.calendar-body-content-header-item {
    display: flex;
    min-width: 100px;
    min-height: 55px;
    align-items: center;
    justify-content: center;
    border: 1px solid #000000;
    border-left: 0px;
    /* cursor: pointer; */
    /* width: 200px; */
}

.calendar-body-content-header-item:first-child{
    position: sticky!important;
    top: 0;
    left: 0;
    background-color: white; /* 设置背景颜色，避免滚动时内容穿透 */
    z-index: 999; /* 设置 z-index，确保表头显示在内容之上 */
    width: 100px;
}

.calendar-body-content-header-item:nth-of-type(1) {
    border-left: 1px solid #000000;
}

.calendar-body-content-header-item-text {
    font-size: 14px;
    color: #333;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.calendar-body-content-header-item-text div{
margin:5px 0;
}

.calendar-body-content-body {}

.calendar-body-content-body1 {
    display: inline-flex;
    /* width: 100%; */
    
}

/* .calendar-body-content-body-item:hover{
    background-color: #ccc;
}
.calendar-body-content-header-item:hover{
    background-color: #ccc;
} */
.calendar-body-content-body2-item:hover {
    background-color: #e3f170;
}

.calendar-body-content-body-item {
    display: flex;
    min-width: 100px;
    min-height: 55px;
    align-items: center;
    justify-content: center;
    border: 1px solid #000000;
    border-top: 0px;
    /* cursor: pointer; */
    width: 100px;
    height: auto;
}

.calendar-body-content-body-item:nth-of-type(1) {
    border-top: 0px;
}

.calendar-body-content-body-item-content {
    margin: 10px;
    width: 80%
}

.calendar-body-content-body2-item {
    display: inline-flex;
    min-width: 100px;
    min-height: 55px;
    align-items: center;
    justify-content: center;
    border: 1px solid #000000;
    border-top: 0px;
    border-left: 0px;
    cursor: pointer;
    width: 100px;
    height: auto;
}

.calendar-body-content-item {
    display: inline-flex;
    width: 100%;
}

.calendar-body-content-body2-item-choose1 {
    background-color: lightgoldenrodyellow;
}

.calendar-body-content-body2-item-choose2 {
    background-color: lightgoldenrodyellow;
}

.calendar-body-content-body2-item-choose3 {
    background-color: lightgray;
}

.calendar-body-content-body2-item-choose4 {
    background-color: lightgoldenrodyellow;
}

.calendar-body-content-body2-item-choose5 {
    background-color: lightgreen;
}

.paiduiwei{
    background-color: lightcoral;
}

 .calendar-body-content-body2-item-choose { /*原待确定 */
    background-color: #ccc;
}
.calendar-body-content-body2-item-choose-sure { /*原已确定 */
    background-color: #34b562;
}

/* .calendar-body-content-body-name:nth-of-type(1) {
    position: absolute;
    background-color: #FFFFFF;
    width: 100px;
} */



/* .calendar-body-content-body2-item:nth-of-type(1) {
    margin-left: 100px;
} */

/* .calendar-body-content-header-item:nth-of-type(1) {
    position: absolute;
    background-color: #FFFFFF;
    width: 100px;
} */

/* .calendar-body-content-header-item:nth-of-type(2) {
    margin-left: 100px;
} */

.calendar-body-content-body-item-content-time-text {
    text-overflow: ellipsis;
    overflow: hidden;
    width: 80px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    display: -webkit-box;
}
.calendar-container{
    height: 85%;
}

.body-box {
    position: relative; /* 确保父容器有定位上下文 */
    height: 100%;
    overflow-y: auto;
    padding:0 20px;
}

.calendar-body {
    overflow-x: scroll;
    height: 100%;
}

.calendar-body-content{
    height: 100%;
}

.calendar-body-content-body{
    height: 100%;
    overflow-y: auto;
}
/* 设置 sticky-header 类的样式 */
.sticky-header {
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 992;
}
.fixed-header:first-child {
    position: sticky;
    top: 0;
    background-color: white;
    /* 设置背景颜色，避免内容重叠 */
    z-index: 993;
    /* 确保在其他内容之上 */
}
/* 固定列样式 */
.sticky-column {
    position: sticky;
    left: 0;
    background-color: white;
    z-index: 991;
}
.corner-cell {
    z-index: 993;
    /* 左上角单元格层级最高 */
}

</style>

<style lang="sass" scoped>
</style>